/**
 * Written By: MinHo Kim (minho.kim.korea@gmail.com)
 * Copyright (C) 2011, MinHo Kim, Software Expert Program, KAIST University, Seoul, Korea.
 * This program is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU General Public License as published 
 * by the Free Software Foundation; version 2 of the License.
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
 * See the GNU General Public License for more details.
 */
package kaist.sep502.tsp.controller;

import kaist.sep502.tsp.model.CityPath;
import kaist.sep502.tsp.model.Problem;
import kaist.sep502.tsp.util.StopWatch;

/**
 * @author minho kim
 *
 */
public class Solution {
	private CityPath goalCityPath;
	private StopWatch stopWatch;
	public long expandedNodeCount = 0;
	private boolean isSuccess;
	
	public Solution(){
		expandedNodeCount = 0;
	}
	
	public void startStopWatch(){
		stopWatch = new StopWatch();
	}
	
	public void stopStopWatch(){
		stopWatch.stop();
	}
	
	/**
	 * @return
	 */
	public CharSequence successMessage() {
		String newLine = "\r\n";
		StringBuilder sb = new StringBuilder();
		
		sb.append("Elapsed TIME: ").append(stopWatch).append(newLine);
		sb.append("EXPANDED COUNT : ").append(this.expandedNodeCount).append(" City Size : ").append(Problem.getCitySize()).append(newLine);
		if(goalCityPath != null){
			sb.append("PATH : ").append(goalCityPath.getPathListString()).append(newLine);
			sb.append("PATH COST : ").append(goalCityPath.getPathCost()).append(newLine);
		}
		
		return sb;
	}

	/**
	 * @return the goalCityPath
	 */
	public CityPath getGoalCityPath() {
		return goalCityPath;
	}

	/**
	 * @param goalCityPath the goalCityPath to set
	 */
	public void setGoalCityPath(CityPath goalCityPath) {
		this.goalCityPath = goalCityPath;
	}

	/**
	 * @return the isSuccess
	 */
	public boolean isSuccess() {
		return isSuccess;
	}

	/**
	 * @param isSuccess the isSuccess to set
	 */
	public void setSuccess(boolean isSuccess) {
		this.isSuccess = isSuccess;
	}
}
